<?
/**
*ip:闸机IP地址	
*command：1开闸，2关闸，3.落杠，4.重启
*personcount：人数
**/
$lhs_array = array('ip'=>'10.14.127.212','command'=>1,'personcount'=>3);
$lhs_data = json_decode(Gate_post($lhs_array),true);
print_r($lhs_data);
function Gate_post($array){
	$o=""; 
	foreach ($array as $k=>$v){ 
		$o.= "$k=".urlencode($v)."&"; 
	}
	// $url='http://jtsvn.eicp.net:8077/et/ticketchecking/opengate/cmd.do';
	$url='http://s1.jiutianda.cn/et/ticketchecking/opengate/cmd.do';
	
	$post_data=substr($o,0,-1);	

	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_POST, 1); 
	curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);  
	curl_setopt($ch, CURLOPT_URL,$url); 	
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	// return curl_exec($ch);
	$result = curl_exec($ch);
    if (!$result) {  
        return curl_error($ch);  
    }else {  
        return $result;  
    }     
}

?>